package com.yt.server.common.dao;

import java.util.List;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import com.yt.server.common.taglib.PageController;

public abstract class BaseDaoImpl<T> extends JdbcDaoSupport implements
		BaseDao<T> {

	@Override
	public void create(T entity) throws Exception {
	}

	@Override
	public void delete(List<Long> entity) throws Exception {
	}

	@Override
	public void edit(T entity) throws Exception {
	}

	@Override
	public T view(T entity) throws Exception {
		return null;
	}

	@Override
	public PageController<?> pageList(String entity, int page) throws Exception {
		return null;
	}

	@Override
	public List<?> list(Object entity) throws Exception {
		return null;
	}

	protected Long getSequenceId(String seq) {
		StringBuffer sql = new StringBuffer();
		sql.append("select nextval('").append(seq).append("')");
		return getJdbcTemplate().queryForLong(sql.toString());
	}

	protected Integer getRowCount(String sqlstr) throws Exception {
		Integer result = 0;
		try {
			result = getJdbcTemplate().queryForInt(sqlstr);
		} catch (Exception e) {
			throw new RuntimeException("获取数据数量时异常", e);
		}
		return result;
	}
}
